package com.jl.jlapp.popu;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.jl.jlapp.R;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ChooseSendToTimePopu extends PopupWindow implements OnClickListener {
    TextView chooseTimeBottomBtn;
    RelativeLayout chooseTimePopup;
    ImageView closeBtn;
    Context context;
    Date date;
    TextView deliveryToName;
    private OnClickBottomOKBtn onClickBottomOKBtn;
    TextView presellSendTime;
    String saveChooseTime = "";
    TextView sendTime1;
    TextView sendTime2;
    TextView sendTime3;
    TextView sendTime4;
    TextView sendTime5;
    TextView sendTime6;
    TextView sendTime7;
    SimpleDateFormat simpleDateFormat;
    List<TextView> textViews;
    LinearLayout timeLinear1;
    LinearLayout timeLinear2;
    private View view;

    public ChooseSendToTimePopu(final Context paramContext, String paramString1, final Integer paramInteger, String paramString2) {
        super(paramContext);
        this.context = paramContext;
        this.saveChooseTime = paramString1;
        this.view = ((LayoutInflater) paramContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.choose_send_to_time_pop, null);
        this.deliveryToName = ((TextView) this.view.findViewById(R.id.delivery_to_name));
        this.chooseTimePopup = ((RelativeLayout) this.view.findViewById(R.id.choose_time_popup));
        this.chooseTimeBottomBtn = ((TextView) this.view.findViewById(R.id.choose_time_bottom_btn));
        this.timeLinear1 = ((LinearLayout) this.view.findViewById(R.id.time_linear_1));
        this.timeLinear2 = ((LinearLayout) this.view.findViewById(R.id.time_linear_2));
        this.presellSendTime = ((TextView) this.view.findViewById(R.id.presell_send_time));
        this.closeBtn = ((ImageView) this.view.findViewById(R.id.close_btn));
        this.sendTime1 = ((TextView) this.view.findViewById(R.id.send_time_1));
        this.sendTime2 = ((TextView) this.view.findViewById(R.id.send_time_2));
        this.sendTime3 = ((TextView) this.view.findViewById(R.id.send_time_3));
        this.sendTime4 = ((TextView) this.view.findViewById(R.id.send_time_4));
        this.sendTime5 = ((TextView) this.view.findViewById(R.id.send_time_5));
        this.sendTime6 = ((TextView) this.view.findViewById(R.id.send_time_6));
        this.sendTime7 = ((TextView) this.view.findViewById(R.id.send_time_7));
        this.textViews = new ArrayList();
        this.textViews.add(this.sendTime1);
        this.textViews.add(this.sendTime2);
        this.textViews.add(this.sendTime3);
        this.textViews.add(this.sendTime4);
        this.textViews.add(this.sendTime5);
        this.textViews.add(this.sendTime6);
        this.textViews.add(this.sendTime7);
        if (paramInteger.intValue() == 2) {
            this.timeLinear1.setVisibility(View.VISIBLE);
            this.timeLinear2.setVisibility(View.VISIBLE);
            this.presellSendTime.setVisibility(View.GONE);
            int i = 0;
            if (i < 7) {
                ((TextView) this.textViews.get(i)).setOnClickListener(this);
                ((TextView) this.textViews.get(i)).setText(getDay(i + 1));
                if (getDay(i + 1).equals(paramString1)) {
                    ((TextView) this.textViews.get(i)).setBackgroundResource(R.drawable.send_to_time_green_border);
                    ((TextView) this.textViews.get(i)).setTextColor(paramContext.getResources().getColor(R.color.checkGreenColor));
                }else  {
                    i += 1;
                    ((TextView) this.textViews.get(i)).setBackgroundResource(R.drawable.send_to_time_gray_background);
                    ((TextView) this.textViews.get(i)).setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
                }
            }
        } else {
            this.deliveryToName.setText("送货时间提示");
            this.timeLinear1.setVisibility(View.GONE);
            this.timeLinear2.setVisibility(View.GONE);
            this.presellSendTime.setVisibility(View.VISIBLE);
            this.presellSendTime.setText("送货时间为活动结束后7日内(结束时间:" + paramString2 + ")");
        }
        setContentView(this.view);
        setWidth(-1);
        setHeight(-1);
        setFocusable(true);
        setAnimationStyle(R.style.AnimBottom);
        setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(paramContext,R.color.white)));
        this.view.setOnTouchListener(new OnTouchListener() {
            public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent) {
                int i = ChooseSendToTimePopu.this.chooseTimePopup.getTop();
                int j = (int) paramAnonymousMotionEvent.getY();
                if ((paramAnonymousMotionEvent.getAction() == 1) && (j < i)) {
                    ChooseSendToTimePopu.this.dismiss();
                }
                return true;
            }
        });
        this.chooseTimeBottomBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                Log.d("ChooseSendToTimePopuaa", "我点击了确定");
                if (paramInteger.intValue() == 2) {
                    if ("请选择".equals(ChooseSendToTimePopu.this.saveChooseTime)) {
                        Toast.makeText(paramContext, "请选择配送时间", Toast.LENGTH_SHORT).show();
                    }
                    while (ChooseSendToTimePopu.this.onClickBottomOKBtn == null) {
                        return;
                    }
                    ChooseSendToTimePopu.this.onClickBottomOKBtn.onClickBottomOkBtn(ChooseSendToTimePopu.this.saveChooseTime);
                    return;
                }
                ChooseSendToTimePopu.this.dismiss();
            }
        });
        this.closeBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                ChooseSendToTimePopu.this.dismiss();
            }
        });
    }

    private String getDay(int paramInt) {
        this.date = new Date();
        this.simpleDateFormat = new SimpleDateFormat("M月d日");
        return this.simpleDateFormat.format(Long.valueOf(this.date.getTime() + 86400000 * paramInt));
    }

    public void onClick(View paramView) {
        Log.d("ChooseSendToTimePopuaa", "执行了点击事件");
        int i = 0;
        if (i < 7) {
            if (paramView.getId() == ((TextView) this.textViews.get(i)).getId()) {
                ((TextView) this.textViews.get(i)).setBackgroundResource(R.drawable.send_to_time_green_border);
                ((TextView) this.textViews.get(i)).setTextColor(this.context.getResources().getColor(R.color.checkGreenColor));
                this.simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                this.saveChooseTime = this.simpleDateFormat.format(Long.valueOf(this.date.getTime() + 86400000 * (i + 1)));
            }else {
                ((TextView) this.textViews.get(i)).setBackgroundResource(R.drawable.send_to_time_gray_background);
                ((TextView) this.textViews.get(i)).setTextColor(this.context.getResources().getColor(R.color.trans_333333));
            }
        }
    }

    public void setSetOnClickBottomOKBtn(OnClickBottomOKBtn paramOnClickBottomOKBtn) {
        this.onClickBottomOKBtn = paramOnClickBottomOKBtn;
    }

    public static abstract interface OnClickBottomOKBtn {
        public abstract void onClickBottomOkBtn(String paramString);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/popu/ChooseSendToTimePopu.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */